

<div style="padding: 15px;">
<a class="layui-btn"  href="/admin/role/addRole">添加角色</a>





<div id="table" style="width:100%"></div>
</div>

<script type="text/html" id="bar">

  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
 
</script>
<script>

layui.use('table', function(){
  table = layui.table;

  tableobj = table.render({
    elem: '#table'
    ,url:'/admin/role/getInfo'
   
    ,cols: [[
     // {field:'update_time', title: '更新时间',unresize:true}
      {field:'id',width:100, type:'normal', title: 'ID', }
      ,{field:'role_name',width:150,title: '角色名称'}
     
 ,{field:'create_time',  title: '创建时间'}

     ,{field:'update_time', width:170, title: '更新时间'}
      ,{field:'active',width:100, title: '操作',toolbar: '#bar'}
    ]]


    ,page:{
    	layout:['prev','page','next','count','skip'],
    	prev:'上一页',
    	next:'下一页',
    	limit:5,

    }

     ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
     	
     	return {
     		"code":res.code,
     		"count": res.total,

    		"data": res.role //解析数据列表
     	}

    }
  });
   table.on('tool()', function(obj){
    var data = obj.data;
  	if(obj.event === 'edit'){
      window.location.href = "/admin/role/edit/"+data.id;
    }
  });

});

</script>